package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TestOrder;
import com.ruoyi.system.service.ITestOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单信息(shardingSphere分表测试)Controller
 * 
 * @author ruoyi
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/system/testOrder")
public class TestOrderController extends BaseController
{
    @Autowired
    private ITestOrderService testOrderService;

    /**
     * 查询订单信息(shardingSphere分表测试)列表
     */
    @PreAuthorize("@ss.hasPermi('system:testOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(TestOrder testOrder)
    {
        startPage();
        List<TestOrder> list = testOrderService.selectTestOrderList(testOrder);
        return getDataTable(list);
    }

    /**
     * 导出订单信息(shardingSphere分表测试)列表
     */
    @PreAuthorize("@ss.hasPermi('system:testOrder:export')")
    @Log(title = "订单信息(shardingSphere分表测试)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TestOrder testOrder)
    {
        List<TestOrder> list = testOrderService.selectTestOrderList(testOrder);
        ExcelUtil<TestOrder> util = new ExcelUtil<TestOrder>(TestOrder.class);
        util.exportExcel(response, list, "订单信息(shardingSphere分表测试)数据");
    }

    /**
     * 获取订单信息(shardingSphere分表测试)详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:testOrder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id, @RequestParam("beginTime") String beginTime, @RequestParam("endTime") String endTime)
    {
        return AjaxResult.success(testOrderService.selectTestOrderById(id, beginTime, endTime));
    }

    /**
     * 新增订单信息(shardingSphere分表测试)
     */
    @PreAuthorize("@ss.hasPermi('system:testOrder:add')")
    @Log(title = "订单信息(shardingSphere分表测试)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TestOrder testOrder)
    {
        return toAjax(testOrderService.insertTestOrder(testOrder));
    }

    /**
     * 修改订单信息(shardingSphere分表测试)
     */
    @PreAuthorize("@ss.hasPermi('system:testOrder:edit')")
    @Log(title = "订单信息(shardingSphere分表测试)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TestOrder testOrder)
    {
        return toAjax(testOrderService.updateTestOrder(testOrder));
    }

    /**
     * 删除订单信息(shardingSphere分表测试)
     */
    @PreAuthorize("@ss.hasPermi('system:testOrder:remove')")
    @Log(title = "订单信息(shardingSphere分表测试)", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids, @RequestParam("beginTime") String beginTime, @RequestParam("endTime") String endTime)
    {
        return toAjax(testOrderService.deleteTestOrderByIds(ids, beginTime, endTime));
    }
}
